package top.sxlai.controller;

import top.sxlai.entity.DTO.OpFileDTO;
import top.sxlai.entity.OpFile;
import top.sxlai.service.IFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * @author : sxl
 * @date : 2024/4/13 9:08
 * @Version: 1.0
 */
@RestController
public class FileController {
    @Autowired
    private IFileService iFileService;
    @PostMapping("/uploadFile")
    public ResponseEntity<Map<String,String>> uploadFile(@RequestParam("file")MultipartFile file,
                                                         @RequestParam("hdfsFolderPath")String hdfsFolderPath) throws Exception {
        OpFileDTO opFileDTO = new OpFileDTO();
        opFileDTO.setFileFolderPath(hdfsFolderPath);
        return iFileService.upLoadFile(file,opFileDTO);
    }
    @PostMapping("/queryFile")
    public ResponseEntity<List<OpFile>> queryFile(@RequestBody OpFileDTO opFile) throws Exception {
        return iFileService.queryFile(opFile);
    }
}
